/**
 * 
 */
package com.hundsun.monitor.server.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.hundsun.monitor.shared.model.MonitorErrorLog;

@Repository
public class MonitorErrorLogDAO {

	@Autowired
	private HibernateTemplate hibernate;
	
	@SuppressWarnings("unchecked")
	public List<MonitorErrorLog> list() {
		String queryStr = "from " + MonitorErrorLog.class.getSimpleName() + " fetch all properties";
		Query query = getCurrentSession().createQuery(queryStr);
		return (List<MonitorErrorLog>)query.list();
	}
	
	private Session getCurrentSession() {
		return hibernate.getSessionFactory().getCurrentSession();
	}
	
}
